package monster.com.cvh.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.text.ParseException;
import java.util.List;

import monster.com.cvh.R;
import monster.com.cvh.bean.CollectionBean;
import monster.com.cvh.util.TimeConvert;
import monster.com.cvh.util.TimeUtil;

/**
 * @author: monster
 * @data: 2018/3/29
 * @function: 我的浏览 Adapter
 */
public class LookedAdapter extends BaseQuickAdapter<CollectionBean.DataBean,BaseViewHolder> {
    public LookedAdapter(int layoutResId, @Nullable List<CollectionBean.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CollectionBean.DataBean item) {
        Glide.with(mContext).load(item.getUrl()).into((ImageView) helper.getView(R.id.item_collection_pic));
        helper.setText(R.id.item_collection_title,item.getTitle());
        //获取当前时间戳
        long timeStamp = System.currentTimeMillis()/1000;
        try {
            String s = TimeConvert.dateToStamp(item.getTime());
            long articleTime = timeStamp - Long.valueOf(s)/1000;
            String lastTime = TimeUtil.calculateTime(articleTime);
            helper.setText(R.id.item_collection_time, lastTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }

    }
}
